package com.mashensoft.interceptor;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

public class LoginIntercepor implements Interceptor{

	public void destroy() {
		System.out.println("拦截器被干掉了");
		
	}

	public void init() {
		System.out.println("拦截器初始化了");
		
	}
	//拦截方法
	public String intercept(ActionInvocation invocation) throws Exception {
		//1：在请求被拦截之前，我们可以获取请求头和参数
		//2：执行action
		//3：执行完action
		HttpServletRequest request = ServletActionContext.getRequest();
		System.out.println("拦截器启动了");
		String result = invocation.invoke();
		System.out.println(request.getParameter("sName"));
		System.out.println(request.getParameter("password"));
		System.out.println("拦截器停止了");
		return result;
	}

}
